#!/bin/csh -f
#
#===============================================================================
# do_newdoc
#===============================================================================
#
# Fill a directory with the template files for a new document.
#
# Usage: do_newdoc <comp> <document type> 
#
#        <comp> is the name of the component, library, or module used as the
#               basis for document filenames (e.g., coupler)
#
#        <document type> is one of the following:
#               req  - requirements document
#               arch - architecture document
#               des  - detailed design document
#               ref  - reference manual
#               usr  - user's guide
#        
# If a directory called <comp> doesn't already exist, it will be created in 
# the directory where the script is called.  If the <comp> directory does exist, 
# the template files needed to create the new document will be added to it.  
# Template files that relate to the entire component have <comp> as the root 
# of their filename.  Template files that pertain to classes or modules have 
# "class" as the root of their filename.
#
# C. DeLuca                                                       March 21, 2001
#===============================================================================

if($#argv != 2) then
  echo "Usage:  do_newdoc <component> <document type>"
  exit
else 
  set comp=$1
  set newdir=$cwd/$1

# Create a new directory if needed
  if(!(-d $newdir)) then
    mkdir $newdir 
  endif 

  set DOCT_DIR=$DOC_DIR/templates

# Fill the directory with template files
  switch ($2) 
  case req:
      if(!(-r $newdir/README_REQ)) cp $DOCT_DIR/README_REQ $newdir
      if(!(-r $newdir/$1_reqdoc.tex)) cp $DOCT_DIR/comp_reqdoc.tex $newdir/$1_reqdoc.tex
      if(!(-r $newdir/$1_syn.tex)) cp $DOCT_DIR/comp_syn.tex $newdir/$1_syn.tex
      if(!(-r $newdir/$1_alg.tex)) cp $DOCT_DIR/comp_alg.tex $newdir/$1_alg.tex
      if(!(-r $newdir/$1_req.tex)) cp $DOCT_DIR/comp_req.tex $newdir/$1_req.tex
      if(!(-r $newdir/$1_glos.tex)) cp $DOCT_DIR/comp_glos.tex $newdir/$1_glos.tex
      if(!(-r $newdir/$1.bib)) cp $DOCT_DIR/comp.bib $newdir/$1.bib
      breaksw
  case arch:
      if(!(-r $newdir/README_ARCH)) cp $DOCT_DIR/README_ARCH $newdir
      if(!(-r $newdir/$1_archdoc.tex)) cp $DOCT_DIR/comp_archdoc.tex $newdir/$1_archdoc.tex
      if(!(-r $newdir/$1_syn.tex)) cp $DOCT_DIR/comp_syn.tex $newdir/$1_syn.tex
      if(!(-r $newdir/$1_alg.tex)) cp $DOCT_DIR/comp_alg.tex $newdir/$1_alg.tex
      if(!(-r $newdir/$1_req.tex)) cp $DOCT_DIR/comp_req.tex $newdir/$1_req.tex
      if(!(-r $newdir/$1_arch.tex)) cp $DOCT_DIR/comp_arch.tex $newdir/$1_arch.tex
      if(!(-r $newdir/$1_glos.tex)) cp $DOCT_DIR/comp_glos.tex $newdir/$1_glos.tex
      if(!(-r $newdir/$1.bib)) cp $DOCT_DIR/comp.bib $newdir/$1.bib
      breaksw
  case des:
      if(!(-r $newdir/README_DES)) cp $DOCT_DIR/README_DES $newdir
      if(!(-r $newdir/$1_desdoc.tex)) cp $DOCT_DIR/comp_desdoc.tex $newdir/$1_desdoc.tex
      if(!(-r $newdir/$1_syn.tex)) cp $DOCT_DIR/comp_syn.tex $newdir/$1_syn.tex
      if(!(-r $newdir/$1_alg.tex)) cp $DOCT_DIR/comp_alg.tex $newdir/$1_alg.tex
      if(!(-r $newdir/$1_req.tex)) cp $DOCT_DIR/comp_req.tex $newdir/$1_req.tex
      if(!(-r $newdir/$1_arch.tex)) cp $DOCT_DIR/comp_arch.tex $newdir/$1_arch.tex
      if(!(-r $newdir/class_desc.tex)) cp $DOCT_DIR/class_desc.tex $newdir
      if(!(-r $newdir/class_rest.tex)) cp $DOCT_DIR/class_rest.tex $newdir
      if(!(-r $newdir/class_fparam.tex)) cp $DOCT_DIR/class_fparam.tex $newdir
      if(!(-r $newdir/class_fex.tex)) cp $DOCT_DIR/class_fex.tex $newdir      
      if(!(-r $newdir/prologue.F)) cp $DOCT_DIR/prologue.F $newdir      
      if(!(-r $newdir/$1_glos.tex)) cp $DOCT_DIR/comp_glos.tex $newdir/$1_glos.tex
      if(!(-r $newdir/$1.bib)) cp $DOCT_DIR/comp.bib $newdir/$1.bib
      breaksw
  case ref
      if(!(-r $newdir/README_REF)) cp $DOCT_DIR/README_REF $newdir
      if(!(-r $newdir/$1_refdoc.tex)) cp $DOCT_DIR/comp_refdoc.tex $newdir/$1_refdoc.tex
      if(!(-r $newdir/$1_syn.tex)) cp $DOCT_DIR/comp_syn.tex $newdir/$1_syn.tex
      if(!(-r $newdir/$1_alg.tex)) cp $DOCT_DIR/comp_alg.tex $newdir/$1_alg.tex
      if(!(-r $newdir/$1_req.tex)) cp $DOCT_DIR/comp_req.tex $newdir/$1_req.tex
      if(!(-r $newdir/$1_arch.tex)) cp $DOCT_DIR/comp_arch.tex $newdir/$1_arch.tex
      if(!(-r $newdir/class_desc.tex)) cp $DOCT_DIR/class_desc.tex $newdir
      if(!(-r $newdir/class_rest.tex)) cp $DOCT_DIR/class_rest.tex $newdir
      if(!(-r $newdir/class_fparam.tex)) cp $DOCT_DIR/class_fparam.tex $newdir
      if(!(-r $newdir/class_fex.tex)) cp $DOCT_DIR/class_fex.tex $newdir      
      if(!(-r $newdir/prologue.F)) cp $DOCT_DIR/prologue.F $newdir      
      if(!(-r $newdir/$1_glos.tex)) cp $DOCT_DIR/comp_glos.tex $newdir/$1_glos.tex
      if(!(-r $newdir/$1.bib)) cp $DOCT_DIR/comp.bib $newdir/$1.bib
      breaksw
  case usr
      if(!(-r $newdir/README_USR)) cp $DOCT_DIR/README_USR $newdir
      if(!(-r $newdir/$1_usrdoc.tex)) cp $DOCT_DIR/comp_usrdoc.tex $newdir/$1_usrdoc.tex
      breaksw
  case all
      if(!(-r $newdir/README_REQ)) cp $DOCT_DIR/README_REQ $newdir
      if(!(-r $newdir/README_ARCH)) cp $DOCT_DIR/README_ARCH $newdir
      if(!(-r $newdir/README_DES)) cp $DOCT_DIR/README_DES $newdir
      if(!(-r $newdir/README_REF)) cp $DOCT_DIR/README_REF $newdir
      if(!(-r $newdir/README_USR)) cp $DOCT_DIR/README_USR $newdir
      if(!(-r $newdir/$1_reqdoc.tex)) cp $DOCT_DIR/comp_desdoc.tex $newdir/$1_reqdoc.tex
      if(!(-r $newdir/$1_archdoc.tex)) cp $DOCT_DIR/comp_desdoc.tex $newdir/$1_archdoc.tex
      if(!(-r $newdir/$1_desdoc.tex)) cp $DOCT_DIR/comp_desdoc.tex $newdir/$1_desdoc.tex
      if(!(-r $newdir/$1_refdoc.tex)) cp $DOCT_DIR/comp_desdoc.tex $newdir/$1_refdoc.tex
      if(!(-r $newdir/$1_usrdoc.tex)) cp $DOCT_DIR/comp_desdoc.tex $newdir/$1_usrdoc.tex
      if(!(-r $newdir/$1_syn.tex)) cp $DOCT_DIR/comp_syn.tex $newdir/$1_syn.tex
      if(!(-r $newdir/$1_alg.tex)) cp $DOCT_DIR/comp_alg.tex $newdir/$1_alg.tex
      if(!(-r $newdir/$1_req.tex)) cp $DOCT_DIR/comp_req.tex $newdir/$1_req.tex
      if(!(-r $newdir/$1_arch.tex)) cp $DOCT_DIR/comp_arch.tex $newdir/$1_arch.tex
      if(!(-r $newdir/class_desc.tex)) cp $DOCT_DIR/class_desc.tex $newdir
      if(!(-r $newdir/class_rest.tex)) cp $DOCT_DIR/class_rest.tex $newdir
      if(!(-r $newdir/class_fparam.tex)) cp $DOCT_DIR/class_fparam.tex $newdir
      if(!(-r $newdir/class_fex.tex)) cp $DOCT_DIR/class_fex.tex $newdir      
      if(!(-r $newdir/prologue.F)) cp $DOCT_DIR/prologue.F $newdir      
      if(!(-r $newdir/$1_glos.tex)) cp $DOCT_DIR/comp_glos.tex $newdir/$1_glos.tex
      if(!(-r $newdir/$1.bib)) cp $DOCT_DIR/comp.bib $newdir/$1.bib
      breaksw
  default:
    echo "Valid options are: req des arch ref usr all"
    exit
  endsw
endif







